package com.guigu.gulisearch.controller;

import com.guigu.gulicommon.entity.pojo.res.Res;
import com.guigu.gulisearch.entity.dto.ProductSearchDto;
import com.guigu.gulisearch.entity.vo.ProductSearchVo;
import com.guigu.gulisearch.service.MallSearchService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 陈俊杰
 * @version 1.0
 * @since 2024/9/9 23:47
 */
@RestController
@RequestMapping("/es/search")
@Log4j2
@Validated
public class SearchController {
    @Autowired
    private MallSearchService mallSearchService;

    /**
     * 商品检索
     *
     * @param dto 商品检索参数
     * @return 商品检索结果
     */
    @PostMapping("/product")
    public Res<ProductSearchVo> search(@RequestBody @Validated ProductSearchDto dto) {
        log.info("商品检索参数：{}", dto);
        return mallSearchService.search(dto);
    }
}
